package com.zmx.patientend.adapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.wang.adapters.interfaceabstract.OnItemClickListener;
import com.zmx.patientend.R;
import com.zmx.patientend.pojo.Department;
import com.zmx.patientend.pojo.DepartmentCategory;
import com.zmx.patientend.view.activity.RegistrationListActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
*时间：2020/5/4 15:47
*功能：挂号右边的适配器
*/

public class DepartmentRightApadter  extends BaseAdapterRvList<CheckDiseaseRightAdapter.ViewHolder, Department> {


    public DepartmentRightApadter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(CheckDiseaseRightAdapter.ViewHolder holder, int listPosition, Department ds) {

        holder.mTvBiaoTi.setText(ds.getF_name());

        holder.mRv.setLayoutManager(new GridLayoutManager(mActivity, 2));

        DepartmentRightItemApadter adapter = new DepartmentRightItemApadter(mActivity);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            protected void onItemClick(View view, int listPosition) {

                Intent intent = new Intent();
                intent.putExtra("dc", ds.getLists().get(listPosition));
                intent.setClass(mActivity, RegistrationListActivity.class);
                mActivity.startActivity(intent);

            }
        });
        holder.mRv.setAdapter(adapter);
        holder.mRv.setNestedScrollingEnabled(false);//设置内层rv不可滑动

        adapter.setListAndNotifyDataSetChanged(ds.getLists());

    }

    @NonNull
    @Override
    protected CheckDiseaseRightAdapter.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {
        CheckDiseaseRightAdapter.ViewHolder holder = new CheckDiseaseRightAdapter.ViewHolder(inflater.inflate(R.layout.apadter_department_right, parent, false));
        return holder;
    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.tv_liandongrightada_BiaoTi)
        TextView mTvBiaoTi;
        @BindView(R.id.rv_liandongrightada)
        RecyclerView mRv;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
